#@layout()

#define script()
#end
#define content()

    <section class="content-header">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-6">

                    <div class="row mb-2">
                        <div class="col-sm-12">
                            <h1>
                                #(coupon ? '编辑':'新增')优惠券
                                <small data-toggle="tooltip" title="" data-placement="right"
                                       data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                                <small> 首页 / 财务 / 优惠券 /  #(coupon ? '编辑':'新增')优惠券</small>
                            </h1>
                        </div>
                    </div>
                </div>

            </div>

        </div><!-- /.container-fluid -->
    </section>



    <section class="content">

        <div class="container-fluid">
                <div class="card card-outline card-primary">

                    <form class=" form-setting autoAjaxSubmit" autocomplete="off"
                          action="#(CPATH)/admin/finance/coupon/doSave"
                          method="POST"
                          data-ok-href="#(CPATH)/admin/finance/coupon/list"
                    >
                        <input type="hidden" name="coupon.id" value="#(coupon.id ??)">
                        <input type="hidden" name="coupon.create_user_id" value="#(coupon.create_user_id ?? USER.id)">
                        <div class="card-body">

                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">优惠券名称</label>
                                <div class="col-sm-6">
                                    <input type="input" name="coupon.title" class="form-control" value="#(coupon.title ??)"
                                           placeholder="例如：无门槛50元优惠券 | 单品最高减2000元">
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">类型</label>
                                <div class="col-sm-6">
                                    <select class="form-control" name="coupon.type" >
                                        <option value="1" #selectedIf(coupon && coupon.type == 1)>
                                            满减券
                                        </option>
                                        <option value="2" #selectedIf(coupon && coupon.type == 2)>
                                            叠加满减券
                                        </option>
                                        <option value="3" #selectedIf(coupon && coupon.type == 3)>
                                            无门槛券
                                        </option>
                                    </select>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">优惠券金额</label>
                                <div class="col-sm-6">
                                    <input type="input" name="coupon.amount" class="form-control" value="#(coupon.amount ??)"
                                           placeholder="">
                                    <p class="text-muted">单位：元。 </p>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">发行量</label>
                                <div class="col-sm-6">
                                    <input type="input" name="coupon.quota" class="form-control" value="#(coupon.quota ??)"
                                           placeholder="">
                                    <p class="text-muted">一共发布多少个优惠券。 </p>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">满多少可用</label>
                                <div class="col-sm-6">
                                    <input type="input" name="coupon.with_amount" class="form-control" value="#(coupon.with_amount ??)"
                                           placeholder="">
                                    <p class="text-muted">仅满减券可用。 </p>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">是否是推广券</label>
                                <div class="col-sm-6">
                                    <input type="checkbox" class="switchery" data-for="with_award" #checkedIf(coupon && coupon.with_award)>
                                    <input type="hidden" id="with_award" name="coupon.with_award">
                                    <p class="text-muted">优惠券的拥有者可以把自己的优惠券给别人用，当优惠券被别人使用后，优惠券的拥有者可以获得奖励金额。 </p>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">消费后奖励金额</label>
                                <div class="col-sm-6">
                                    <input type="input" name="coupon.award_amount" class="form-control" value="#(coupon.award_amount ??)"
                                           placeholder="">
                                    <p class="text-muted">启用 [推广券] 后有效，优惠券拥有者获得的奖励。 </p>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">只有会员可用</label>
                                <div class="col-sm-6">
                                    <input type="checkbox" class="switchery" data-for="with_member" #checkedIf(coupon && coupon.with_member)>
                                    <input type="hidden" id="with_member" name="coupon.with_member">
                                    <p class="text-muted">必须是会员的用户才可以使用。 </p>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">是否可用多次</label>
                                <div class="col-sm-6">
                                    <input type="checkbox" class="switchery" data-for="with_multi" #checkedIf(coupon && coupon.with_multi)>
                                    <input type="hidden" id="with_multi" name="coupon.with_multi">
                                    <p class="text-muted">只要不过期，可以使用该优惠券购买多次产品。 </p>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">只有领取人可用</label>
                                <div class="col-sm-6">
                                    <input type="checkbox" class="switchery" data-for="with_owner" #checkedIf(coupon && coupon.with_owner)>
                                    <input type="hidden" id="with_owner" name="coupon.with_owner">
                                    <p class="text-muted">只能是优惠券领取人可用，不能分享给其他人。 </p>
                                </div>
                            </div>






                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">验证类型</label>
                                <div class="col-sm-6">
                                    <select class="form-control" name="coupon.valid_type">
                                        <option value="1" #selectedIf(coupon && coupon.valid_type == 1)>
                                            绝对时效（XXX ~ XXX时间段内有效）
                                        </option>
                                        <option value="2" #selectedIf(coupon && coupon.valid_type == 2)>
                                            相对时效（领取后 X 天有效）
                                        </option>
                                    </select>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">绝对时效</label>
                                <div class="col-sm-6">
                                    <input type="input" name="coupon.valid_start_time" class="form-control datetime" value="#date(coupon.valid_start_time ??)"
                                           placeholder="" style="width: 48%;display: initial">
                                    <div style="float: right;display: contents">
                                        至
                                    </div>
                                    <input type="input" name="coupon.valid_end_time" class="form-control datetime" value="#date(coupon.valid_end_time ??)"
                                           placeholder=""  style="width: 48%;display: initial">
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">相对时效</label>
                                <div class="col-sm-6">
                                    <input type="input" name="coupon.valid_days" class="form-control" value="#(coupon.valid_days ??)"
                                           placeholder="">
                                    <p class="text-muted">单位：天，用户领取优惠券后多少天内有效。 </p>
                                </div>
                            </div>


                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label">状态</label>
                                <div class="col-sm-6">
                                    <select class="form-control" name="coupon.status">
                                        <option value="1" #selectedIf(coupon && coupon.status == 1)>
                                            正常可用
                                        </option>
                                        <option value="9" #selectedIf(coupon && coupon.status == 9)>
                                            失效
                                        </option>
                                    </select>
                                    <p class="text-muted">选择 失效 后，该优惠券下的所有券将会立即失效。 </p>
                                </div>
                            </div>




                        </div>
                        <!-- /.card-body -->
                        <div class="card-footer">
                            <div class="offset-sm-2 col-sm-10 submit-block">
                                <div class="card-submit">
                                    <button type="submit" class="btn btn-primary">提交</button>
                                </div>
                            </div>
                        </div>
                        <!-- /.card-footer -->
                    </form>
                </div>
            </div>
        </div>

    </section>

#end
